#ifndef _CPP_STORY_WORLD_H_
#define _CPP_STORY_WORLD_H_

#include <string>
#include <vector>
#ifdef WIN32
#include "cppstory_win32.h"
#endif

namespace CppStory
{

class Background;
class Feature;
class Output;
class Scenario;
class Step;
class StepDefinition;

#ifdef WIN32
class CPPSTORY_WIN32_API World
#else
class World
#endif
{
public:
    static World* instance();
    static void destroy();
    static World* create();

    bool run(Output* out);

    void register_feature(Feature *f);
    std::vector< Feature* > features;
    Feature* get_cur_feature() { return cur_feature; }

    void register_step_def(StepDefinition *s);
    std::vector< StepDefinition* > step_defs;
    StepDefinition* get_cur_step_def() { return cur_step_def; }

    std::vector< Feature* > successful_features;
    std::vector< Feature* > failed_features;

    ~World();
private:
    World();
    Feature* cur_feature;
    StepDefinition* cur_step_def;
    Output* output;
    bool background_failed;
    bool match_step_defs();
    bool match_step_defs_of_feature(Feature* feature);
    bool match_step_defs_of_scenario(Scenario* scenario);
    bool match_step_defs_of_steps(std::vector< Step* > &steps);
    void replace();

    void output_features();
    void output_feature(Feature* feature);
    void output_background(Background* background);
    void output_scenarios(Feature* feature);
    void output_scenario(Scenario* scenario);
    void output_steps(std::vector< Step* > &steps);
    void output_summary();
};

}

#endif

